package com.sky.controller.websites;

import com.sky.context.BaseContext;
import com.sky.dto.WebListDTO;
import com.sky.result.Result;
import com.sky.service.WebsitesService;
import com.sky.vo.WebListChildVO;
import com.sky.vo.WebListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 贾晓晨
 * @version 1.0
 */
@RestController
@RequestMapping("/friend")
@Slf4j
@Api(tags = "友情链接")
public class WebSitesController {
    @Autowired
    private WebsitesService websitesService;

    @GetMapping
    @ApiOperation("获取所有的友情链接")
    public Result<List<WebListChildVO>> getFriendShip() {
        // Long currentPermission = BaseContext.getCurrentPermission();
        // WebListVO retList = new WebListVO();
        // 获取两种
        // retList = websitesService.getWebListByAdmin();

        // retList = websitesService.getWebListByCommon();
        List<WebListChildVO> webListChildVO = websitesService.getWebList();
        return Result.success(webListChildVO);
    }

    @PostMapping("save")
    @ApiOperation("保存友情链接请求")
    public Result saveFriendPost(@RequestBody WebListDTO webListDTO) {
        websitesService.saveFriendPost(webListDTO);
        return Result.success("保存成功");
    }
}
